﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace 练习9
{
    internal class MyNum
    {
        public int Outnumber;
        string[] strRestring = new string[] { "Is Null Or Empty","Not a number", "negative", "zero", "positive" };
        public User CheckNum(string Instring)
        {
            User user=new User();
            user.bIsnull = false;
            if (string.IsNullOrEmpty(Instring))         { user.Msg = strRestring[0]; return user; }
            if (!int.TryParse(Instring, out Outnumber)) { user.Msg = strRestring[1]; return user; }
            if (Outnumber  < 0) { user.Msg = strRestring[2]; }
            if (Outnumber == 0) { user.Msg = strRestring[3]; }
            if (Outnumber  > 0) { user.Msg = strRestring[4]; }
            return user;
        }
        public User CheckNum1(string Instring) 
        {
            User user = new User();
            user.bIsnull = false;
            if (string.IsNullOrEmpty(Instring))         { user.Msg = strRestring[0]; return user; }
            if (!int.TryParse(Instring, out Outnumber)) { user.Msg = strRestring[1]; return user; }
            switch (Outnumber>0?1:(Outnumber<0?-1:0))
            {
                case -1:  user.Msg = strRestring[2]; break;
                case  0:  user.Msg = strRestring[3]; break;  
                case  1:  user.Msg = strRestring[4]; break;
                default:  user.Msg = strRestring[1]; break;
            }
            return user;
        }
    }
}
